#ifndef LOGINDIALOG_H
#define LOGINDIALOG_H
#include <QDialog>
#include <QLabel>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QComboBox>



#include <users/user.h>
#include <users/userslist.h>

namespace login_and_registration {
class LoginDialog : public QDialog
{
	/*!
	 '''Turns Login Dialog into a QObject
	*/
	Q_OBJECT

   private:
	/*!
	* A label for the username component.
	*/
	QLabel *labelUsername;

	/*!
	 * A label for the password.
	 */
	QLabel *labelPassword;

	QLabel *labelUserCorrect;

	/*!
	 * An editable combo box for allowing the user
	 * to enter his username or select it from a list.
	 */
	QComboBox *comboUsername;

	/*!
	 * A field to let the user enters his password.
	 */
	QLineEdit *editPassword;

	/*!
	 * The standard dialog button box.
	 */
	QDialogButtonBox *buttons;

	QPushButton *addUserButton;

	QPushButton *closeButton;

	users::usersList& list;

	int counter{0};



public:
	explicit LoginDialog(users::usersList &list, QWidget *parent = nullptr);

	/*!
	* Sets the proposed username, that can come for instance
	* from a shared setting.
	'''username the string that represents the current username
	''' to display
	*/
	void setUsername( QString& username );

	/*!
	* Sets the current password to propose to the user for the login.
	* password the password to fill into the dialog form
	*/
	void setPassword( QString& password );


signals:
	/*!
	 * A signal emitted when the login is performed.
	 * username the username entered in the dialog
	 * password the password entered in the dialog
	 * index the number of the username selected in the combobox
	 */
	void acceptLogin(const users::user& user);

public slots:
	 /*!
	 * A lot to adjust the emitting of the signal.
	 */
	void slotAcceptLogin();


	void addUser();

	void resetCounter();

};
}
#endif // LOGINDIALOG_H
